<% layout('/layout/default.html', {title: '待办任务', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-cubes"></i> 待办任务
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="查询" ><i class="fa fa-filter"></i> 查询</a>
			</div>
		</div>
		<script type="text/javascript">
			/**
			 * 签收任务
			 */
			function claim(taskId) {
				$.get('${ctx}/act/task/claim' ,{taskId: taskId}, function(data) {
					if (data == 'true'){
			        	$.jBox.tip('签收完成');
			            location = '${ctx}/act/task/todo/';
					}else{
			        	$.jBox.tip('签收失败');
					}
			    });
			}
		</script>
		<div class="box-body">
			<form id="searchForm" action="${ctx}/act/task/todoData" method="post" class="form-inline hide" >
				<div class="form-group">
					<label class="control-label">流程分类：</label>
					<div class="control-inline">
						<#form:select path="category" name="label" data="getDictList:act_category" class="form-control required">
						</#form:select>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">创建时间：</label>
					<div class="control-inline">
						<input id="beginDate" name="beginDate" maxlength="64" readonly="readonly" class="form-control required "
								value="" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});" /> -
						<input id="endDate" name="endDate" maxlength="64" readonly="readonly" class="form-control required "
								value="" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});" />
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">查询</button>
					<button type="reset" class="btn btn-default btn-sm">重置</button>
				</div>
			</form>			
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
//初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'流程名称', name:'procDefname', index:'', width:100, align:"center"},
		{header:'当前环节', name:'taskName', index:'', width:90, align:"center",formatter: function(val, obj, row, act){
			return '<a href="${ctx}/act/task/diagramViewer?definitionId='+row.procDefId+ '&instanceId=' + row.procInsId +'" class="btnList" title="流程图查看" data-type="diagram">' +val+ '</a>'
		}},
		{header:'流程版本', name:'procDefversion', index:'', width:80, align:"center", formatter: function(val, obj, row, act){
			return "V:" + val;
		}},
		{header:'创建时间', name:'createTime', index:'', width:100, align:"center", formatter: "date",formatoptions:{srcformat: 'Y-m-d H:i:s',newformat: 'Y-m-d H:i:s'}},
		{header:'操作', name:'actions', width:100, sortable:false, title:false, align:"center",formatter: function(val, obj, row, act){
			
			var actions = [];
			if(row.assignee == null || row.assignee.length == 0) {
				actions.push('<a href="${ctx}/act/task/claim?taskId=' + row.taskId+ '" class="btnList" title="签收任务" data-confirm="确认要签收该任务吗？">签收任务</a>&nbsp;');
			} else {
				actions.push('<a href="/act/task/form?taskId=' + row.taskId+ '&taskName='+ row.taskName + '&taskDefKey=' + row.taskDefKey + '&procInsId=' + row.procInsId + '&procDefId=' + row.procDefId + '&status=' + row.status + '" class="btnList" title="任务办理" >任务办理</a>&nbsp;');
			}
			<%if(hasPermi("act:process:edit")){%>
				if(row.executionId == "") {
					actions.push('<a href="${ctx}/act/task/deleteTask?taskId=' + row.taskId +'&reason=" class="btnList" title="删除" data-prompt="输入删除原因并确认："><i class="fa fa-trash-o"></i></a>&nbsp;');
				}
			<%}%>
			
			actions.push('<a href="${ctx}/act/task/diagramViewer?definitionId='+row.procDefId+ '&instanceId=' + row.procInsId +'" class="btnList" title="流程图查看" data-type="diagram">跟踪</a>');
			return actions.join('');	
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>